<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.commons.SessionKeys,
                 com.scalar.chiptrack.utils.ConfigManager,
				 com.scalar.chiptrack.commons.Constants,
				 com.scalar.chiptrack.users.Functionality,
				 com.scalar.chiptrack.users.User"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/sortRelease.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet"></HEAD>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/assembly_release.js"></script>

<SCRIPT language="JavaScript">

function save()
{
    var lotSize = document.sortReleaseForm.lotSize.value;
    var waferSize = document.sortReleaseForm.waferSize.value;
    var errors = '';
    var temp = document.sortReleaseForm['sortRelease.sortRelDate'];
    if( chkDate(temp.value.trim(),"Release Date ","Y") == false)
    {
        errors = errMsg;
        temp.select();
        temp.focus();
    }
    var vendorContactPersonEmail = document.sortReleaseForm['sortRelease.vendContactPersonEmail'];
    if( vendorContactPersonEmail.value.trim().length > 0 && !isValidEMailId (vendorContactPersonEmail))
    {
        errors = errors + '<li> Please enter a valid email address for Vendor Contact Person';
        vendorContactPersonEmail.select();
        vendorContactPersonEmail.focus();
    }
    var specialInstrLength = document.sortReleaseForm['sortRelease.specialInstr'].value.length;
    if( specialInstrLength > 200 )
    {
        errors = errors + "<li> Special Instructions Should be Maximum of 200 Characters";
        document.sortReleaseForm['sortRelease.specialInstr'].select();
        document.sortReleaseForm['sortRelease.specialInstr'].focus();
    }

    var specFileName = document.sortReleaseForm['sortRelease.specificationFileSetupForm.specifincationFileName'].value;
    if( specFileName == "" )
    {
        errors = errors + "<li> Please Set up the Specification File for the Part  Number";
    }
    var waferSelected = false;
    for( var i=0; i < lotSize; i++ )
    {
        for( var j=0; j < waferSize; j++ )
        {
            document.sortReleaseForm[ 'sortRelease.sortReleaseLotList['+i+'].waferList['+j+'].selected' ].disabled = false;
            if( document.sortReleaseForm[ 'sortRelease.sortReleaseLotList['+i+'].waferList['+j+'].selected' ].checked == true )
            {
                waferSelected = true;
            }
        }
    }
    if( waferSelected == false )
    {
        errors = errors + '<li> Please Select atleast one wafer for Wafer Sort Release'
    }
    if ( errors != '' )
    {
        var pa=document.getElementById("errors");
        pa.innerHTML = errors;
        return;
    }
    document.sortReleaseForm['sortRelease.sortRelNumber'].disabled = false;
    document.sortReleaseForm.action="<%=chipTracContext%>/sortRelease.do?action=save"
    document.sortReleaseForm.submit();
}

function reset()
{
    document.sortReleaseForm.reset();
}

function addmore()
{
    document.sortReleaseForm.action="<%=chipTracContext%>/sortRelease.do?action=addmore"
    document.sortReleaseForm.submit();
}
var dateElement = "";
function openCalendar( dateValue )
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.focus();
}
function assignDate( passedValue )
{
    dateElement.value=passedValue;
    window.focus();
}

</SCRIPT>

<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
	<TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

	<!-- Side Navigation start -->
	<%@ include file="/jsp/operations/releaseMenu.jsp" %></TD>
	<!-- end of the side navigations -->

	<TD bgcolor="#ffffff">
	<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	<TD valign="top" width="100%">

	<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	<BR>

	<html:form action="/sortRelease" enctype="multipart/form-data"  method="POST">
    <nested:nest property="sortRelease" >
		<TABLE width="90%" align="right" cellpadding="2" cellspacing="2" border="0">
			<TR>
                <TD colspan="4" class="NArialW" align="center">&nbsp;&nbsp;&nbsp;Wafer Sort Release</TD>
            </TR>
            <logic:equal name="showMessage" value="TRUE">
                <tr><td colspan="4" align='left'><font class='NArialS'color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></td></tr>
            </logic:equal>
			<TR><TD colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></TD></TR>
			<TR><TD colspan='4' class="NArialL"><chiptrack:errors styleClass="NArialL"/></TD></TR>
			<TR><TD colspan='4' class="NArialL"><chiptrack:info styleClass="NArialL"/></TD></TR>
			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
			<tr>
			<td class="NArialL" width="20%">
				Sort Release #:<font color=red>*</font>
			</td>
			<td class="NArialL" width="25%">
                <nested:text property="sortRelNumber" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
			</td>
			<td class="NArialL" width="20%">
				Release Date:<font color=red>*</font>
			</td>
			<td class="NArialL" width="25%">
			    <nested:text property="sortRelDate" size="20" styleClass="txfield" />
                <a href="javascript:openCalendar( document.sortReleaseForm['sortRelease.sortRelDate'] )">
                    <img onMouseOver="window.status='Click  to select date';return true" onMouseout="window.status='';return 	true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20>
                </a>
			</td>
			</tr>
			<tr>
			<td class="NArialL" width="20%">
				Part Number:
			</td>
			<td class="NArialL" width="25%">
			    <nested:text property="partNumber" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
			</td>
			<td class="NArialL" width="20%">
              Wafer Sort PO #:
			</td>
            <td class="NArialL" width="25%">
			    <nested:text property="sortRelPO" size="20" maxlength="50"  styleClass="txfield"/>
			</td>
            </tr>

            <nested:iterate property="contactPersonsList" id="contactPerson" indexId="itIndex" >
                <tr>
                <td class="NArialL" width="20%">
                    Contact Person<%=itIndex.intValue()+1%>:
                </td>
                <td class="NArialL" width="25%">
                    <nested:text property="name" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
                </td>
                <td class="NArialL" width="20%">
                    Contact Person Email<%=itIndex.intValue()+1%>:
                </td>
                <td class="NArialL" width="25%">
                    <nested:text property="email" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
                </td>
                </tr>
            </nested:iterate>

			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr>
            <td class="NArialL" width="20%">
                Vendor Name:
			</td>
            <td class="NArialL" width="25%">
			    <nested:text property="vendName" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
			</td>
            <td class="NArialL" width="20%">
                Sort Revision:
			</td>
            <td class="NArialL" width="25%">
			    <nested:text property="sortRevision" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
			</td>
			</tr>
            <tr>
            <td class="NArialL" width="20%">
                Vendor Contact Person:
			</td>
            <td class="NArialL" width="25%">
			    <nested:text property="vendContactPerson" size="20" maxlength="50"  styleClass="txfield" maxlength='50'/>
			</td>
            <td class="NArialL" width="20%">
                Vendor Contact Person Email:
			</td>
            <td class="NArialL" width="25%">
			    <nested:text property="vendContactPersonEmail" size="20" maxlength="50"  styleClass="txfield" maxlength='100'/>
			</td>
			</tr>
            <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <TR>
                <TD colspan='4' class="NArialL">
                    <table width="90%" align="left" cellpadding="2" cellspacing="2" border="0">
                        <nested:iterate property="sortReleaseLotList" type="com.scalar.chiptrac.operations.release.SortReleaseLot">
                            <tr>
                                <td colspan="5" class="NArialL" align="left">Wafer Information for Lot Number : <nested:write property="lotNumber"/></td>
                            </tr>
                        </nested:iterate>
                         <tr>
                            <td colspan="5" class="NArialL" nowrap>
                               <nested:size id='lotSize' property='sortReleaseLotList'/>
                               <input type='hidden' name='lotSize' value='<%=lotSize%>'/>
                               <nested:iterate property="sortReleaseLotList" type="com.scalar.chiptrac.operations.release.SortReleaseLot">
                                    <%int i=0; %>
                                    <table width="90%" align="center" cellpadding="2" cellspacing="2" border="0">
                                    <nested:size id='waferSize' property='waferList'/>
                                    <input type='hidden' name='waferSize' value='<%=waferSize%>'/>
                                    <nested:iterate property="waferList" type="com.scalar.chiptrac.operations.release.SortReleaseWafer" indexId="iteratIdx">
                                        <%if(i%5 == 0 ){%><TR><%}%>
                                        <TD  class="NArialL">
                                        <nested:equal property='disabled' value="true">
                                            <nested:checkbox property="selected" styleClass="txfield" disabled="true"/>&nbsp;
                                            Wafer-<nested:write property="waferId"/>&nbsp;&nbsp;&nbsp;
                                        </nested:equal>
                                        <nested:notEqual property='disabled' value="true">
                                            <nested:checkbox property="selected" styleClass="txfield" />&nbsp;
                                            Wafer-<nested:write property="waferId"/>&nbsp;&nbsp;&nbsp;
                                        </nested:notEqual>
                                        </TD>
                                        <%i++;%>
                                    </nested:iterate>
                                    </table>
                               </nested:iterate>
                            </td>
                        </tr>

                    </table>
                </TD>
            </TR>
            <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr>
            <td class="NArialL" width="20%">
                Special Instructions:
			</td>
            <td class="NArialL" width="25%">
			    <nested:textarea property="specialInstr" styleClass="txfield" cols="30" rows="5"/>
			</td>
            <td class="NArialL"colspan="2" width="20%">&nbsp;</td>

			</tr>
            <tr><td colspan="2" align="center">&nbsp;</td></tr>
            
            
            <!-- BR 23 2005 START -->
			<nested:nest property="specificationFileSetupForm" >
            <tr>
	            <td class="NArialL" width="20%">
	                Spec File Name:
				</td>

	            <td class="NArialL" width="25%">
	                <nested:text property="specifincationFileName" size="20" styleClass="txfield" maxlength='100' disabled="true"/>
				</td>

	            <td class="NArialL" width="20%">
	                Test Spec Rev:
				</td>

	            <td class="NArialL" width="25%">
	                <nested:text property="revisionNumber" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
				</td>
			</tr>
			
            <tr>
	            <td class="NArialL" width="20%">
	                Test Program:
				</td>

	            <td class="NArialL" width="25%">
	                <nested:text property="testProgramName" size="20" styleClass="txfield" maxlength='100' disabled="true"/>
				</td>

	            <td class="NArialL" width="20%">
	                Test Program Revision:
				</td>

	            <td class="NArialL" width="25%">
	                <nested:text property="testProgramRevision" size="20" maxlength="50"  styleClass="txfield" disabled="true"/>
				</td>
			</tr>

            <tr>
	            <td class="NArialL" width="20%">
	                Test Flow:
				</td>

	            <td class="NArialL" width="25%">
	                <nested:text property="testFlow" size="20" styleClass="txfield" maxlength='100' disabled="true"/>
				</td>

	            <td class="NArialL" width="20%">
					&nbsp;
				</td>

	            <td class="NArialL" width="25%">
	                &nbsp;
				</td>
			</tr>

			</nested:nest>
            <!-- BR 23 2005 END -->
            <tr>
	            <td class="NArialL" width="20%">
	                Freight Carrier:
				</td>

	            <td class="NArialL" width="25%">
	                <nested:text property="shipperName" size="20" styleClass="txfield" maxlength='100' disabled="true"/>
				</td>

	            <td class="NArialL" width="20%">
					&nbsp;
				</td>

	            <td class="NArialL" width="25%">
	                &nbsp;
				</td>
			</tr>
            <tr><td colspan="2" align="center">&nbsp;</td></tr>
            <tr>
				<td class="NArialL" colspan='4'>
					Shipping Address:
				</td>
			</tr>
			<tr>
				<td class="NArialL">
					Contact Person:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.contactPerson" size="20" styleClass="txfield"/>
				</td>
				<td class="NArialL">
					Email:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.email" size="20" styleClass="txfield"/>
				</td>
			</tr>

			<tr>
				<td class="NArialL">
					Phone:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.phoneNumber" size="20" styleClass="txfield"/>
				</td>
				<td class="NArialL">
					Fax:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.faxNumber" size="20" styleClass="txfield"/>
				</td>
			</tr>
			<tr>
				<td class="NArialL">
					Address1:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.address1" size="20" styleClass="txfield"/>
				</td>
				<td class="NArialL">
					Address2:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.address2" size="20" styleClass="txfield"/>
				</td>
			</tr>
			<tr>
				<td class="NArialL">
					Address3:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.address3" size="20" styleClass="txfield"/>
				</td>
				<td class="NArialL">
					Address4:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.address4" size="20" styleClass="txfield"/>
				</td>
			</tr>
			<tr>
				<td class="NArialL">
					City:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.city" size="20" styleClass="txfield"/>
				</td>
				<td class="NArialL">
					State:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.state" size="20" styleClass="txfield"/>
				</td>
			</tr>
			<tr>
				<td class="NArialL">
					Country:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.country" size="20" styleClass="txfield"/>
				</td>
				<td class="NArialL">
					Zip:
				</td>
				<td class="NArialL">
					<nested:text property="shiptoAddress.zipCode" size="20" styleClass="txfield"/>
				</td>
			</tr>
            <tr><td colspan="4" align="center">&nbsp;</td></tr>
			<tr>
				<td colspan="4" align="center">
                <chiptrack:restrictedLink functionality='<%=Functionality.SORT_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:save();' onmouseover="window.status='Click to Save Wafer Sort Release';return true" onmouseout="window.status='';return true">
                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" title="Click here to Save Sort Release"/>
                </chiptrack:restrictedLink>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
				</td>
			</tr>
            <tr><td colspan="4" align="center">&nbsp;</td></tr>
		</TABLE>
        </nested:nest>
	</html:form>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>